$(document).ready(function(){
    var names = {
        'qiancheng':'前程无忧',
        'zhilian':'智联招聘',
        'boss':'boss直聘',
        'lagou':'拉勾网'
    };

    $('.available-platforms img').click(function(e){
        var platform = $(e.target).attr('plat');

        $('.platform-account-input input').val('');
        $('.platform-account-input').removeClass('hidden').attr('platform',platform);
        $('.platform-account-input-header b').text(names[platform] + '账号配置');
    });

    $('.platform-account-input .btn-light').click(function(){
        $('.platform-account-input').addClass('hidden');
    });

    $('.platform-account-input .btn-danger').click(function(){
        var accountName  = $('.platform-account-input .accountName').val();
        var accountPwd = $('.platform-account-input .accountPwd').val();
        var platform = $('.platform-account-input').attr('platform');

        if(accountName.length == 0 || accountPwd.length == 0){
            return alert('账号名称和密码都不能为空');
        }

        $.ajax({
            'url':'/platform_account_info.do',
            'data':{
                'accountName':accountName,
                'accountPwd':accountPwd,
                'platform':platform
            },
            'success':function(resp){
                if(resp.success){
                    alert('成功提交');
                    $('.platform-account-input').addClass('hidden');
                }
            }
        });
    });
});